/*
 * \brief  Helper for creating specialized capability types
 * \author Norman Feske
 * \date   2008-08-15
 */

/*
 * Copyright (C) 2008-2009 Norman Feske
 * Genode Labs, Feske & Helmuth Systementwicklung GbR
 *
 * This file is part of the Genode OS framework, which is distributed
 * under the terms of the GNU General Public License version 2.
 */

#ifndef _INCLUDE__BASE__TYPED_CAPABILITY_H_
#define _INCLUDE__BASE__TYPED_CAPABILITY_H_

#include <base/capability.h>

namespace Genode {

	/**
	 * Typed capability
	 *
	 * \param IT   capability-interface type
	 * \param BCT  base capability type
	 *
	 * The IT template argument is used to create different
	 * and incompatible types for different capability interfaces.
	 */
	template <typename IT, typename BCT = Capability>
	class Typed_capability : public BCT
	{
		public:

			/**
			 * Constructor to be used by the capability producer
			 *
			 * This constructor should only be used for converting
			 * the untyped capability returned by 'Entrypoint::manage()'
			 * to the specialized capability type matching the RPC
			 * interface.
			 */
			explicit Typed_capability(Capability cap) : BCT(cap) { }

			/**
			 * Default constructor creates invalid capability
			 */
			Typed_capability() : BCT() { }
	};
}

#endif /* _INCLUDE__BASE__TYPED_CAPABILITY_H_ */
